﻿using System;
using StateMachine.TextParsing;
using System.Text;

namespace WpfClient.FunctionFileParsing
{
    public class FunctionFileParserContext : TextParserContext<FunctionFileParsingState>
    {
        public FunctionFileParserContext(FunctionFileParsingState initialState)
            : base(initialState)
        {
            this.Result = new FunctionFileParseResult();
        }

        internal string TextToParse { get; private set; }
        internal StringBuilder Buffer { get; private set; }
        internal bool HasReachedClassDefinition { get; set; }
        internal FunctionFileParseResult Result { get; private set; }

        protected override void ClearOverride()
        {
            this.TextToParse = null;
            this.Buffer = null;
            this.HasReachedClassDefinition = false;
            this.Result = null;
        }

        protected override void InitializeOverride(string text)
        {
            this.TextToParse = text;
            this.Buffer = new StringBuilder();
            this.HasReachedClassDefinition = false;
            this.Result = new FunctionFileParseResult();
            this.Result.ParsedText = text;
        }
    }
}
